package com.pro.common.api.user.model.db;

import com.baomidou.mybatisplus.annotation.TableField;
import com.pro.common.api.CommonConst;
import com.pro.common.api.model.BaseUserModel;
import com.pro.common.api.model.auth.IUserRecordClass;
import com.pro.framework.javatodb.annotation.JTDTable;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;


@Data
@Schema(description = "用户处理批次")
@JTDTable(entityId = 13, module = CommonConst.Modules.user, sequences = {
        "KEY `idx_userId_deleted_createTime` (`user_id`,`deleted`,`create_time`)",
})
@NoArgsConstructor
public class UserBatchInfo extends BaseUserModel implements IUserRecordClass {
    @Schema(description = "业务类型")
    private String businessType;
    @Schema(description = "子业务类型")
    private String subBusinessType;
    @Schema(description = "处理记录行数")
    private Long processSize;
    @Schema(description = "操作者Id")
    private Long createBy;

    @Schema(description = "操作者Id")
    @TableField(exist = false)
    private List<UserBatchDetail> userBatchDetails;

    public UserBatchInfo(Long userId, String businessType, Long processSize) {
        this.businessType = businessType;
        this.processSize = processSize;
        setUserId(userId);
    }
    public UserBatchInfo(Long userId, String businessType, List<UserBatchDetail> userBatchDetails) {
        this.businessType = businessType;
        this.processSize = (long) userBatchDetails.size();
        this.userBatchDetails = userBatchDetails;
        setUserId(userId);
    }
}

